Skip to content

tests: define TA_ASSERT_POLICY before unit_test_config.h tests it - #599

Merged
evaleev merged 1 commit into
masterfrom
fix/unit-test-assert-policy
Oct 29, 2026
Merged

evaleev merged 1 commit into
masterfrom
fix/unit-test-assert-policy

Conversation

@evaleev

@evaleev evaleev commented Oct 28, 2026

Copy link
Copy Markdown
Member

tests/unit_test_config.h tests TA_ASSERT_POLICY == TA_ASSERT_THROW before anything has included TiledArray/config.h. Both macros are undefined at that point, so the condition is 0 == 0 and always true. As a result, BOOST_{WARN,CHECK,REQUIRE}_TA_ASSERT expand to BOOST_*_THROW under every policy, not just THROW.

CI always configures with TA_ASSERT_THROW, so it never notices. A default build (TA_ASSERT_IGNORE) fails conversions_suite/concat with 4 checks of "exception TiledArray::Exception expected but not raised". Those asserts are compiled out, so the expected exception is never thrown.

The fix includes TiledArray/config.h before the test. It also adds an #error if the policy macros are still undefined there, so the check can't silently pass again.

Verified locally (macOS, AppleClang, Release):

  • Before the fix, TA_ASSERT_IGNORE: conversions_suite/concat fails 4 checks.
  • After the fix, TA_ASSERT_IGNORE: check-tiledarray passes, including np=1 and np=2.
  • After the fix, TA_ASSERT_THROW: check-tiledarray passes, including np=1 and np=2.

Found while verifying #598.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VUXmaqVr5HVkrMw6ivrKzF

… unit_test_config.h

The policy was tested before anything defined it, so TA_ASSERT_POLICY == TA_ASSERT_THROW compared
0 == 0 and BOOST_{WARN,CHECK,REQUIRE}_TA_ASSERT expanded to BOOST_*_THROW under every policy; with
TA_ASSERT_IGNORE/ABORT, conversions_suite/concat failed 4 checks. Also #error if the policy is undefined.
@evaleev
evaleev force-pushed the fix/unit-test-assert-policy branch from 121bf30 to 6470522 Compare October 28, 2026 20:41
@evaleev
evaleev merged commit e6ce024 into master Oct 29, 2026
9 checks passed
@evaleev
evaleev deleted the fix/unit-test-assert-policy branch October 29, 2026 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant